package forward.Module.Modules.Render;

import java.awt.Color;

import forward.api.EventHandler;
import forward.api.Events.Render.EventRender2D;
import forward.api.Events.World.EventPreUpdate;
import forward.Module.Module;
import forward.Module.ModuleType;
import forward.UI.ClientNotification;
import forward.Util.ClientUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.util.MathHelper;


public class Health
extends Module {
	int fuck=0;
    private int width;

    public Health() {
        super("Health", new String[]{"Healthy"}, ModuleType.Render);
    }

    @EventHandler
    private void renderHud(EventRender2D event) {
        if (Minecraft.thePlayer.getHealth() >= 0.0f && Minecraft.thePlayer.getHealth() < 10.0f) {
            this.width = 3;
        }
        if (Minecraft.thePlayer.getHealth() >= 10.0f && Minecraft.thePlayer.getHealth() < 100.0f) {
            this.width = 5;
        }
        mc.fontRendererObj.drawStringWithShadow("" + MathHelper.ceiling_float_int((float)Minecraft.thePlayer.getHealth()), (float)(new ScaledResolution(mc).getScaledWidth() / 2 - this.width), (float)(new ScaledResolution(mc).getScaledHeight() / 2 - 5) - (float)((Double)Crosshair.SIZE.getValue()).doubleValue() - (float)((Double)Crosshair.GAP.getValue()).doubleValue(), Minecraft.thePlayer.getHealth() <= 10.0f ? new Color(255, 0, 0).getRGB() : new Color(0, 255, 0).getRGB());
    }
    @EventHandler
	public void onUpdate(EventPreUpdate event) {
    	if (Minecraft.thePlayer.getHealth() >= 0.0f && Minecraft.thePlayer.getHealth() < 6.0f&&fuck==0) {
    		fuck=1;
    		ClientUtil.sendClientMessage("Your HP is low!", ClientNotification.Type.WARNING);
    	}else if (Minecraft.thePlayer.getHealth() >= 0.0f && Minecraft.thePlayer.getHealth() > 6.0f&&fuck==1) {
    		fuck=0;
    	}
    }
}
